﻿using System.Web.Mvc;
using DTD.Repositories;
using DTD.Repositories.Interfaces;
using DTD.Web.Models;
using System.Collections.Generic;

namespace DTD.Web.Controllers
{
    public class MenuController : Controller
    {
        public static int SelectedId = 1;

        ICategoryRepository repository = new CategoryRepository();

        public ActionResult HorizontalMenu()
        {
            List<SelectableCategory> selCats = new List<SelectableCategory>(); 
            
            foreach (Category cat in repository.GetRootCategories()) 
            {
                SelectableCategory selCat = new SelectableCategory();
                selCat.Category = cat;
                selCat.Selected = (cat.Id == SelectedId) ? true : false;
                selCats.Add(selCat);
            }

            return PartialView("Menu", selCats);
        }
    }
}